home *** CD-ROM | disk | FTP | other *** search
/ Family Forum 262 / SOMC Family Forum 262.iso / Xtras / Widget Wizard / Widget Wizard.dir / WidgtBehaviors_47_QTsoundlevel.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  3.6 KB  |  83 lines

  1. property downState, boundingsprite, Slider, background, upstate, VideoSprite
  2.  
  3. on getPropertyDescriptionList
  4.   set description to [:]
  5.   if the currentSpriteNum = 0 then
  6.     set memdefault to 0
  7.   else
  8.     set memref to the member of sprite the currentSpriteNum
  9.     set castLibNum to the castLibNum of memref
  10.     set memdefault to member (the memberNum of member memref + 1) of castLib castLibNum
  11.   end if
  12.   addProp(description, #VideoSprite, [#comment: "VideoSprite:", #format: #integer, #default: the currentSpriteNum + 9])
  13.   addProp(description, #downState, [#default: memdefault, #format: #bitmap, #comment: "Pict for Down:"])
  14.   addProp(description, #background, [#comment: "Slider Background Sprite:", #format: #integer, #default: the currentSpriteNum + 1])
  15.   addProp(description, #boundingsprite, [#comment: "Bounding Box Sprite:", #format: #integer, #default: the currentSpriteNum + 2])
  16.   addProp(description, #Slider, [#comment: "Slider Knob Sprite:", #format: #integer, #default: the currentSpriteNum + 3])
  17.   return description
  18. end
  19.  
  20. on getBehaviorDescription
  21.   return "Pops up a slider to set the system volume." & RETURN & "PARAMETERS:" & RETURN & "ΓÇó VideoSprite - set the volume of sprite VideoSprite." & RETURN & "ΓÇó Down Member - the picture of the button when pressed." & RETURN & "ΓÇó Slider Background Sprite - the slider background sprite." & RETURN & "ΓÇó Bounding Box Sprite - the bounding box sprite, make invisible rect." & RETURN & "ΓÇó Slider Knob Sprite - the slider knob sprite."
  22. end
  23.  
  24. on getAssocMembers
  25.   set myPropList to [downState]
  26.   return myPropList
  27. end
  28.  
  29. on beginSprite me
  30.   puppetSprite(the spriteNum of me, 0)
  31.   puppetSprite(background, 0)
  32.   puppetSprite(boundingsprite, 0)
  33.   puppetSprite(Slider, 0)
  34.   set upstate to the member of sprite the spriteNum of me
  35. end
  36.  
  37. on mouseDown me
  38.   puppetSprite(the spriteNum of me, 1)
  39.   puppetSprite(background, 1)
  40.   puppetSprite(boundingsprite, 1)
  41.   puppetSprite(Slider, 1)
  42.   set the member of sprite the spriteNum of me to member downState
  43.   set soundRangeCast to the number of member the castNum of sprite boundingsprite
  44.   set soundHeight to the height of cast soundRangeCast
  45.   set the loc of sprite background to point((the left of sprite boundingsprite + the right of sprite boundingsprite) / 2, (the top of sprite boundingsprite + the bottom of sprite boundingsprite) / 2)
  46.   set the loc of sprite Slider to the loc of sprite boundingsprite
  47.   set gOutLevel to 255 - the volume of sprite Slider
  48.   set the locV of sprite Slider to (gOutLevel * (float(soundHeight) / 255.0)) + the top of sprite boundingsprite
  49.   updateStage()
  50.   set the constraint of sprite Slider to boundingsprite
  51.   repeat while the stillDown
  52.     if rollOver(background) then
  53.       set the locV of sprite Slider to the mouseV
  54.       set gOutLevel to (the mouseV - the top of sprite boundingsprite + 1) / (float(soundHeight) / 255.0)
  55.       updateStage()
  56.     end if
  57.   end repeat
  58.   set the member of sprite the spriteNum of me to upstate
  59.   updateStage()
  60.   if gOutLevel < 0 then
  61.     set gOutLevel to 0
  62.   end if
  63.   if gOutLevel > 240 then
  64.     set gOutLevel to 255
  65.   end if
  66.   set the volume of sprite VideoSprite to 255 - gOutLevel
  67.   set the loc of sprite background to point(1000, 1000)
  68.   set the loc of sprite boundingsprite to point(1000, 1000)
  69.   set the loc of sprite Slider to point(1000, 1000)
  70.   puppetSprite(the spriteNum of me, 0)
  71.   puppetSprite(background, 0)
  72.   puppetSprite(boundingsprite, 0)
  73.   puppetSprite(Slider, 0)
  74. end
  75.  
  76. on endSprite me
  77.   puppetSprite(the spriteNum of me, 0)
  78.   puppetSprite(background, 0)
  79.   puppetSprite(boundingsprite, 0)
  80.   puppetSprite(Slider, 0)
  81.   set the constraint of sprite Slider to 0
  82. end
  83.